<%--
  Created by IntelliJ IDEA.
  User: XYC
  Date: 2015/7/9
  Time: 13:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>

<link href="${css}/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="${css}/bootstrap-datetimepicker.min.css"  rel="stylesheet" media="screen">
<link href="${assets}/bootstrapValidator/css/bootstrapValidator.css" rel="stylesheet"/>
<link rel="stylesheet" href="${dean}/css/person.css" type="text/css"/>
<from id="defaultForm" method="post" class="form-horizontal">
    <div class="rol1">
        <p>性别：</p>

        <div class="select">
            <div id="gender" data-value=""></div>
            <span></span>
            <ul class="test">
            </ul>
        </div>
        <p>工作单位：</p>
        <input type="text" id="workCompany"/>

        <p>联系人：</p>
        <input type="text" id="contacts"/>

        <p>血型：</p>

        <div class="select">
            <div id="bloodType" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1" class="first">A型</li>
                <li data-option-value="2" class="none">B型</li>
                <li data-option-value="3" class="none">O型</li>
                <li data-option-value="4" class="none">AB型</li>
            </ul>
        </div>
        <p>HR阴性：</p>

        <div class="select">
            <div id="rhType" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1">不详</li>
            </ul>
        </div>
        <p>援助类型：</p>

        <div class="select">
            <div id="aidType" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1">其他</li>
            </ul>
        </div>
    </div>
    <div class="rol1">

        <p>出生日期：</p>
<%--form-group--%>
        <div class=" date1">
            <div id="birthday" class="input-group date form_date col-md-5" style="width: auto"
                 data-date-format="yyyy-mm-dd">
                <input class="form-control" size="12" type="text" value="${Patient.birthdayOfString}" readonly>
            <span class="input-group-addon">
                <!-- <span><img src="img/calender.png" alt="" /></span> -->
            <span class="glyphicon glyphicon-calendar" aria-hidden="true"></span>
      </span>
            </div>
        </div>
        <!-- <input type="text" id="birthday"/> -->
        <div class=" h56" style="height:56px">
        <p>本人电话：</p>
        <input type="text" id="phone"/>
        </div>
        <div class="h56"  style="height:56px">
            <p>联系人电话：</p>
            <input type="text" id="contactPhone"/>
        </div>
        <div class="h56"  style="height:56px">
        <p>户口性质：</p>

        <div class="select">
            <div id="hukouType" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1">农村户口</li>
                <li data-option-value="2">城镇户口</li>
            </ul>
        </div>
        </div>
        <div class="h56"  style="height:56px">
        <p>职业：</p>

        <div class="select">
            <div id="career" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1">不详</li>
            </ul>
        </div>
        </div>
        <div class="validShow h56"  style="height:27px;margin-bottom: 27px;">
            <p>电子邮箱：</p>
            <input type="text" id="email" name="email" style="margin: 0px;"/>
        </div>
    </div>
    <div class="rol1">
        <div class="h56">
            <p>与户主关系：</p>

            <div class="select">
                <div id="relationship" data-value=""></div>
                <span></span>
                <ul class="test">
                    <li data-option-value="1">户主</li>
                    <li data-option-value="2">父亲</li>
                    <li data-option-value="3">母亲</li>
                </ul>
            </div>
        </div>

        <div class="h56">
        <p>民族：</p>
            <div class="select" style="overflow: hidden;">
                <div id="nationality" data-value=""></div>
                <span></span>
                <ul class="test">
                </ul>
            </div>
        </div>

        <div class="h56">
            <p>文化程度：</p>
            <div class="select">
                <div id="degree" data-value=""></div>
                <span></span>
                <ul class="test">
                    <li data-option-value="1">研究生</li>
                    <li data-option-value="2">本科</li>
                    <li data-option-value="3">专科</li>
                    <li data-option-value="4">高中</li>
                    <li data-option-value="5">初中</li>
                </ul>
            </div>
        </div>
        <div class="h56">
        <p>婚姻状况：</p>
            <div class="select">
                <div id="maritalState" data-value=""></div>
                <span></span>
                <ul class="test">
                    <li data-option-value="1" class="first">未婚</li>
                    <li data-option-value="2" class="none">已婚</li>
                </ul>
            </div>
        </div>

        <div class="h56">
            <p>国籍：</p>
            <div class="select" style="overflow: hidden;">
                <div id="nation" data-value=""></div>
                <span></span>
                <ul class="test">
                    <li data-option-value="1">中国</li>
                    <li data-option-value="2">美国</li>
                    <li data-option-value="3">英国</li>
                </ul>
            </div>
        </div>
        <div class="validShow"  style="height:27px;margin-bottom: 27px;">
            <p class="text">邮编：</p>
            <input type="text" id="postcode" name="postcode" style="margin: 0px;"/>
        </div>
    </div>
    <div class="cl"></div>
    <div class="rol2">
        <p>家庭住址：</p>
        <input type="text" id="homeAddress"/>

        <p>户籍地址：</p>
        <input type="text" id="registerAddress"/>

        <div id="negativeEvents">
            <p>负性事件：</p>
			<span>
				<input type="checkbox" id="death" value="1"/><label for="death">丧偶</label>
			</span>
			<span>
				<input type="checkbox" id="alone" value="3"/><label for="alone">目前独居</label>
				</span>
			<span>
				<input type="checkbox" id="recent" value="2"/><label for="recent">住院治疗</label>
			</span>
			<span>
				<input type="checkbox" id="treated" value="4"/><label for="treated">子女分家</label>
			</span>
			<span>
				<input type="checkbox" id="lose" value="5"/><label for="lose">失去亲人</label>
			</span>
			<span>
				<input type="checkbox" id="other" value="6"/><label for="other">其他</label>
			</span>
        </div>
        <div class="other">
            <input id="negativeEventsExtra" type="text" data-dean-defultView="请输入其他负性事件" value=""/>
        </div>
    </div>
    <div class="rol1">
        <p>常住类型：</p>

        <div class="select">
            <div id="permanentType" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1">中国</li>
                <li data-option-value="2">美国</li>
                <li data-option-value="3">英国</li>
            </ul>
        </div>
        <p>证件类型：</p>

        <div class="select">
            <div id="cardKind" data-value=""></div>
            <span></span>
            <ul class="test">
                <li data-option-value="1">身份证</li>
            </ul>
        </div>
        <p>管理单位：</p>
        <input type="text" id="company"/>

        <p>建档日期：</p>
        <input type="text" id="createdTime"/>
    </div>

    <button class="store" onclick="saveData()">保存</button>
</from>
<%--<script type="text/javascript" src="${js}/jquery.min.js" charset="UTF-8"></script>--%>
<%--<script src="${js}/jquery.min.js"></script>--%>
<script src="${dean}/js/baseDell.js"></script>
<%--<script src="${dean}/js/jquery-1.11.1.min.js"></script>--%>
<script src="${dean}/js/jquery-1.11.1.js"></script>
<!-- jQuery -->
<%--<script src="${js}/jquery-1.9.1.min.js"></script>--%>
<script src="${dean}/js/person1.js" type="text/javascript"></script>
<script type="text/javascript" src="${js}/bootstrap.min.js"></script>
<script type="text/javascript" src="${js}/bootstrap-dateTime/bootstrap-datetimepicker.js" charset="UTF-8"></script>
<script type="text/javascript" src="${js}/bootstrap-dateTime/locales/bootstrap-datetimepicker.zh-CNxyc.js" ></script>
<!-- bootstrapValidator验证 -->
<script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
<!-- bootstrapValidator验证 国际化中文 -->
<script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>

<script type="text/javascript" src="${js}/dean.js" ></script>
<script type="text/javascript">
    /* 表单提交验证*/
    $('#defaultForm').bootstrapValidator({
        message: 'This value is not valid',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            email: {
                group: '.validShow',
                validators: {
                    emailAddress: true
                }
            },
            postcode:{
                group: '.validShow',
                validators: {
//                    notEmpty: true
                    stringLength: {
                        min: 6,
                        max: 6,
                        message:"邮政编码一般为6个数字"
                    }/*,
                    digits:{
                        message:"邮政编码一般皆为数字"
                    }*/
                }
            }
        }
    });
    function buttonInit(){
        $('.store').mouseenter(function(){
            $(this).addClass('act');
        }).mouseleave(function(){
            $(this).removeClass('act');
        });
    }

    function init(){
        $("#birthday").datetimepicker({
          language:  'zh-CN',
          weekStart:  0,
          todayBtn: true,
          autoclose:  1,
          todayHighlight: 1,
          startView: 2,
          minView: 2,
          forceParse: 0
        });
        var patient=${patient};
        <%--var gen =${map};--%>
        addSelectWithLIFormmer(${gender},"#gender","code","name");
        selectOneRowInBackGroundFindByValue("#gender","data-option-value",patient.gender);
    //    $("#gender").val(patient.gender);
        addSelectWithLIFormmer(${relationship},"#relationship","code","name");
        selectOneRowInBackGroundFindByValue("#relationship","data-option-value",patient.relationship);

        $("#workCompany").val(patient.workCompany);
        $("#phone").val(patient.phone);
        addSelectWithLIFormmer(${nationality},"#nationality","code","name");
        selectOneRowInBackGroundFindByValue("#nationality","data-option-value",patient.nationality);

        $("#contacts").val(patient.contacts);
        $("#contactPhone").val(patient.contactPhone);
        addSelectWithLIFormmer(${degree},"#degree","code","name");
        selectOneRowInBackGroundFindByValue("#degree","data-option-value",patient.degree);

        addSelectWithLIFormmer(${bloodType},"#bloodType","code","name");
        selectOneRowInBackGroundFindByValue("#bloodType","data-option-value",patient.bloodType);
        addSelectWithLIFormmer(${hukouType},"#hukouType","code","name");
        selectOneRowInBackGroundFindByValue("#hukouType","data-option-value",patient.hukouType);
        addSelectWithLIFormmer(${maritalState},"#maritalState","code","name");
        selectOneRowInBackGroundFindByValue("#maritalState","data-option-value",patient.maritalState);

        addSelectWithLIFormmer(${rhType},"#rhType","code","name");
        selectOneRowInBackGroundFindByValue("#rhType","data-option-value",patient.rhType);
        addSelectWithLIFormmer(${career},"#career","code","name");
        selectOneRowInBackGroundFindByValue("#career","data-option-value",patient.career);
        addSelectWithLIFormmer(${nation},"#nation","code","name");
        selectOneRowInBackGroundFindByValue("#nation","data-option-value",patient.nation);

        addSelectWithLIFormmer(${aidType},"#aidType","code","name");
        selectOneRowInBackGroundFindByValue("#aidType","data-option-value",patient.aidType);
        $("#email").val(patient.email);
        $("#postcode").val(patient.postcode);

        $("#homeAddress").val(patient.homeAddress);
        addSelectWithLIFormmer(${permanentType},"#permanentType","code","name");
        selectOneRowInBackGroundFindByValue("#permanentType","data-option-value",patient.permanentType);


        $("#registerAddress").val(patient.registerAddress);
        addSelectWithLIFormmer(${cardKind},"#cardKind","code","name");
        selectOneRowInBackGroundFindByValue("#cardKind","data-option-value",patient.cardKind);

        var arrayTemp = patient.negativeEvents;
        var strs = arrayTemp.split("|");
        for(var i=0;i<strs.length-1;i++){//$("#negativeEvents input[type='checkbox'][value='"+strs[i]+"']")
          $("#negativeEvents input[type='checkbox'][value='"+strs[i]+"']").prop('checked',true)
        }

        BindClickWithInputShow("#negativeEvents input[type='checkbox'][value='6']","#negativeEventsExtra","${dean}/img/other_bg");
        $("#negativeEvents input[type='checkbox'][value='6']").click( function(){BindClickWithInputShow("#negativeEvents input[type='checkbox'][value='6']","#negativeEventsExtra","${dean}/img/other_bg")});
        $("#negativeEvents input[type='checkbox'][value='6']").focus(function(){textDefultShow("#negativeEventsExtra",true)});
        $("#negativeEvents input[type='checkbox'][value='6']").blur(function(){textDefultShow("#negativeEventsExtra",false)});
        $("#negativeEventsExtra").val(patient.negativeEventsExtra);
        $("#company").val(patient.company);
        $("#createdTime").val(patient.createdTimeOfString);
        /*
        $("#company").val(patient.company);

        $("#createdTime").val(patient.createdTimeOfString);*/
    }
    $(document).ready(function(){
//    alert("xyc");
        init();
        buttonInit();
    });

    function saveData(){
        var data=new Object();
        data["idCard"]="${Patient.idCard}";
        data["gender"]=$("#gender").attr("data-value");
        data["birthdayOfString"]=$("#birthday .form-control").val();
        data["relationship"]=$("#relationship").attr("data-value");
        data["workCompany"]=$("#workCompany").val();
        data["phone"]=$("#phone").val();
        data["nationality"]=$("#nationality").attr("data-value");
        data["contacts"]=$("#contacts").val();
        data["contactPhone"]=$("#contactPhone").val();
        data["degree"]=$("#degree").attr("data-value");
        data["bloodType"]=$("#bloodType").attr("data-value");
        data["hukouType"]=$("#hukouType").attr("data-value");
        data["maritalState"]=$("#maritalState").attr("data-value");
        data["rhType"]=$("#rhType").attr("data-value");
        data["career"]=$("#career").attr("data-value");
        data["nation"]=$("#nation").attr("data-value");
        data["aidType"]=$("#aidType").attr("data-value");
        data["email"]=$("#email").val();
        data["postcode"]=$("#postcode").val();
        data["homeAddress"]=$("#homeAddress").val();
        data["permanentType"]=$("#permanentType").attr("data-value");
        data["registerAddress"]=$("#registerAddress").val();
        data["cardKind"]=$("#cardKind").attr("data-value");
        data["company"]=$("#company").val();
        data["registerAddress"]=$("#registerAddress").val();
        var temp="";
        $("#negativeEvents input[type=checkbox]:checked").each(function(){
            temp = temp +$(this).val()+"|";
            if($(this).val()==6){
                data["negativeEventsExtra"]=$("#negativeEventsExtra").val();
            }
        });
        data["negativeEvents"]=temp;
        jQuery.ajax({
            url :'${ctx}/web/patient/archives/SaveAndUpdata',
            type : "post",
            data:data,
            cache : false,
            dataType : "json",
            success : function(data){
                alert("提交完成");
            }
        });
//        alert("xyc");
    }
</script>


